﻿using System;
using System.IO;
using Common.Logging;
using System.Reflection;

namespace DotNetNexusSpam
{
    class FileUtil
    {
        private static ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public static bool Delete(string filePath) {
            bool isSuccess = false;
            if (File.Exists(filePath)) {
                try
                {
                    File.Delete(filePath);
                    isSuccess = true;
                }
                catch (Exception exc) {
                    _log.Warn("Email could not be deleted, access was denied.");
                    _log.Warn(exc);
                    isSuccess = false;
                }
            }
            return isSuccess;
        }
    }
}
